Don't ignore errors in workspace manifest
authorAleksey Kladov <aleksey.kladov@gmail.com>
Thu, 15 Dec 2016 17:27:48 +0000 (20:27 +0300)
committerAleksey Kladov <aleksey.kladov@gmail.com>
Thu, 15 Dec 2016 17:27:48 +0000 (20:27 +0300)
src/cargo/core/workspace.rs
tests/workspaces.rs

index d0b0fdeec15c59f32052b0278d57b10936a6b971..c396755e870695ae4c791694006e3cffe5d04e75 100644 (file)
@@ -242,8 +242,8 @@ impl<'cfg> Workspace<'cfg> {
         while let Some(path) = cur {
             let manifest = path.join("Cargo.toml");
             debug!("find_root - trying {}", manifest.display());
-            if let Ok(pkg) = self.packages.load(&manifest) {
-                match *pkg.workspace_config() {
+            if manifest.exists() {
+                match *self.packages.load(&manifest)?.workspace_config() {
                     WorkspaceConfig::Root { .. } => {
                         debug!("find_root - found");
                         return Ok(Some(manifest))
index 579dfa0dbfea77e194591fb8f8ae466a1970c0dc..8204e6c341c8386d5bc49f8aba2196ee6e6e13da 100644 (file)
@@ -1055,3 +1055,22 @@ fn workspace_with_transitive_dev_deps() {
     assert_that(p.cargo("test").args(&["-p", "bar"]),
                 execs().with_status(0));
 }
+
+#[test]
+fn error_if_parent_cargo_toml_is_invalid() {
+    let p = project("foo")
+        .file("Cargo.toml", "Totally not a TOML file")
+        .file("bar/Cargo.toml", r#"
+            [project]
+            name = "bar"
+            version = "0.1.0"
+            authors = []
+        "#)
+        .file("bar/src/main.rs", "fn main() {}");
+    p.build();
+
+    assert_that(p.cargo("build").cwd(p.root().join("bar")),
+                execs().with_status(101)
+                       .with_stderr_contains("\
+[ERROR] failed to parse manifest at `[..]`"));
+}